package Schedule::Chronic::Distributed::Monitor;
=head1 NAME

Schedule::Chronic::Distributed::Monitor - Manage the Scheduler

=head1 SYNOPSIS

    PerlModule Apache::DBI

  <Location /monitor>

    # Provide your own authentication
    AuthName scheduler
    AuthType Basic

    . . .

    # path to monitor maypole templates
    PerlSetEnv TEMPLATE_ROOT /var/www/monitor/templates
    # URI of monitor website (no ending slash)
    PerlSetEnv URI_BASE http://scheduler.domain.tld/monitor
    # DBI DSN for backend database
    PerlSetEnv CHRONIC_DSN dbname=chronic;host=localhost
    SetHandler perl-script
    PerlHandler Schedule::Chronic::Distributed::Monitor

  </Location>


PerlSetEnv TEMPLATE_PATH /usr/share/templates

PerlHandler Schedule::Chronic::Distributed::Monitor

=head1 DESCRIPTION

Web interface to manage and monitor the scheduler.

=head1 METHODS

See Maypole::Model::CDBI for details of default model actions, etc.

=head2 display_columns

returns the columns to be displayed in the order to display them.

=cut

use strict;

use Maypole::Application;
use Data::Dumper;

use Schedule::Chronic::Distributed::Monitor::Task;
use Schedule::Chronic::Distributed::Monitor::TaskHistory;
use Schedule::Chronic::Distributed::Monitor::TaskRequirement;

__PACKAGE__->config->model("Maypole::Model::CDBI::Plain");
__PACKAGE__->setup([
		    qw/Schedule::Chronic::Distributed::Node Schedule::Chronic::Distributed::Requirement
                       Schedule::Chronic::Distributed::Command Schedule::Chronic::Distributed::Category
		       Schedule::Chronic::Distributed::Task Schedule::Chronic::Distributed::TaskTimes
                       Schedule::Chronic::Distributed::TaskHistory Schedule::Chronic::Distributed::PrerequisiteTask
                       Schedule::Chronic::Distributed::TaskRequirement/
		   ]);

__PACKAGE__->config->{uri_base} = $ENV{URI_BASE} || 'http://scheduler.example.com/monitor';
__PACKAGE__->config->{template_root} = $ENV{TEMPLATE_ROOT} || "/var/www/vhosts/schedulemonitor/templates";
__PACKAGE__->config->rows_per_page(8);


Schedule::Chronic::Distributed::Command->untaint_columns( printable => [qw/name path filename description type/], integer => ['category'] );

Schedule::Chronic::Distributed::Requirement->untaint_columns( printable => [qw/name description handler type/], );

Schedule::Chronic::Distributed::PrerequisiteTask->untaint_columns( printable => [qw/latency requisite_state/], integer => [qw/task requisite/] );

Schedule::Chronic::Distributed::Category->untaint_columns( printable => [qw/name path description/] );

Schedule::Chronic::Distributed::TaskTimes->untaint_columns( integer => ['task'], printable =>[qw/start_time end_time/], );

sub Schedule::Chronic::Distributed::TaskTimes::display_columns { return (qw/task start_time end_time/); }

1;


=head1 SEE ALSO

Schedule::Chronic::Distributed

Maypole

=head1 AUTHOR

aaron trevena, E<lt>aaron.trevena@gmail.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2006 by Aaron Trevena

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.5 or,
at your option, any later version of Perl 5 you may have available.

=cut
